import 'package:flutter/material.dart';
import 'package:love_app/common/su.dart';
import 'package:love_app/providers/share_provider.dart';
import 'package:love_app/routes/application.dart';
import 'package:love_app/routes/routes.dart';
import 'package:provider/provider.dart';

// 钱包页面
class MyWallet extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    ShareProvider shareProvider = Provider.of<ShareProvider>(context, listen: false);
    return Scaffold(
      appBar: Su().appBar(
        "我的钱包",
        colors: shareProvider.themeColor,
      ),
      body: _body(context),
    );
  }

  // 页面内容
  Widget _body(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        _walletItem("钻石充值", "images/mine_page/diamond.png", Routes.diamondRecharge, context),
        _walletItem("现金红包", "images/mine_page/red.png", "", context),
      ],
    );
  }

  // 钱包内容
  Widget _walletItem(String name, String imagePath, String routeName, BuildContext context) {
    return InkWell(
      onTap: () {
        Application.router.navigateTo(context, routeName);
      },
      child: Container(
        color: Colors.white,
        width: Su().w(373),
        height: Su().h(189),
        child: _walletItemChild(name, imagePath),
      ),
    );
  }

  // 钱包内容child
  Widget _walletItemChild(String name, String imagePath) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Image.asset(
          imagePath,
          width: Su().w(68),
          height: Su().w(51),
        ),
        Text(
          name,
          style: Su().textStyle(Color.fromRGBO(38, 38, 38, 1), 28),
        ),
      ],
    );
  }
}
